package com.huatai.bi;

import com.huatai.bi.config.ConnectionClickHouseConfig;
import com.huatai.bi.utils.DruidUtils;

import com.huatai.bi.websocket.WebSocket;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @program: ganghua
 * @description: 启动类
 * @author: songxiude
 * @create: 2024-07-25 09:29
 **/
@SpringBootApplication(scanBasePackages = {"com.huatai"})
@MapperScan("com.huatai.bi.mapper")
@EnableFeignClients(basePackages = "com.huatai")
@EnableAsync
public class BiApplication implements CommandLineRunner {
	@Autowired
	private ConnectionClickHouseConfig connectionClickHouseConfig;
	public static void main(String[] args)
	{
		//SpringApplication.run(BiApplication.class, args);
		SpringApplication springApplication = new SpringApplication(BiApplication.class);
		ConfigurableApplicationContext configurableApplicationContext = springApplication.run(args);
		//解决websocket无法注入问题

		WebSocket.setApplicationContext(configurableApplicationContext);
		System.out.println("(♥◠‿◠)ﾉﾞ  BI模块启动成功   ლ(´ڡ`ლ)ﾞ");
	}

	@Override
	public void run(String... args) throws Exception {
		DruidUtils.init(connectionClickHouseConfig);
	}
}
